Re: [PATCH v1 1/2] checkout: factor out functions to new lib file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas Gummerer <t.gummerer@xxxxxxxxx> writes:

> Factor the functions out, so they can be re-used from other places.  In
> particular these functions will be re-used in builtin/worktree.c to make
> git worktree add dwim more.
>
> While there add a description to the function.
>
> Signed-off-by: Thomas Gummerer <t.gummerer@xxxxxxxxx>
> ---
>
> I'm not sure where these functions should go ideally, they don't seem
> to fit in any existing library file, so I created a new one for now.
> Any suggestions for a better home are welcome!
>
>  Makefile           |  1 +
>  builtin/checkout.c | 41 +----------------------------------------
>  checkout.c         | 43 +++++++++++++++++++++++++++++++++++++++++++
>  checkout.h         | 14 ++++++++++++++
>  4 files changed, 59 insertions(+), 40 deletions(-)
>  create mode 100644 checkout.c
>  create mode 100644 checkout.h

I am not sure either.  I've always considered that entry.c is the
libified thing codepath that want to do a "checkout" should call,
but the functions that you are moving is at a "higher layer" that
does not concern the core-git data structures (i.e. the 'tracking'
is a mere "user" of the ref API, unlike things in entry.c such as
checkout_entry() that is a more "maintainer" of the index integrity),
so perhaps it makes sense to have new file for it.

> diff --git a/checkout.c b/checkout.c
> new file mode 100644
> index 0000000000..a9cf378453
> --- /dev/null
> +++ b/checkout.c
> @@ -0,0 +1,43 @@
> +#include "cache.h"
> +

A useless blank line.

> +#include "remote.h"
> +

This one is useful ;-)

> +struct tracking_name_data {
> ...
> diff --git a/checkout.h b/checkout.h
> new file mode 100644
> index 0000000000..9272fe1449
> --- /dev/null
> +++ b/checkout.h
> @@ -0,0 +1,14 @@
> +#ifndef CHECKOUT_H
> +#define CHECKOUT_H
> +
> +#include "git-compat-util.h"
> +#include "cache.h"

Try "git grep -e git-compat-util Documentation/CodingGuidelines" and
just keep inclusion of "cache.h".



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux