git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 1/4] checkout: factor out functions to new lib file

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 24, 2017, 06:47 UTC
Message-ID
<xmqqfu94npga.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171122223020.2780-2-t.gummerer@gmail.com>
Thomas Gummerer <t.gummerer@gmail.com> writes:
Show 39 quoted lines
> 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 some docs to the function.
>
> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
> ---
>  Makefile           |  1 +
>  builtin/checkout.c | 41 +----------------------------------------
>  checkout.c         | 42 ++++++++++++++++++++++++++++++++++++++++++
>  checkout.h         | 13 +++++++++++++
>  4 files changed, 57 insertions(+), 40 deletions(-)
>  create mode 100644 checkout.c
>  create mode 100644 checkout.h
>
> diff --git a/Makefile b/Makefile
> index cd75985991..8d603c7443 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -757,6 +757,7 @@ LIB_OBJS += branch.o
>  LIB_OBJS += bulk-checkin.o
>  LIB_OBJS += bundle.o
>  LIB_OBJS += cache-tree.o
> +LIB_OBJS += checkout.o
>  LIB_OBJS += color.o
>  LIB_OBJS += column.o
>  LIB_OBJS += combine-diff.o
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index fc4f8fd2ea..9e1cfd10b3 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1,5 +1,6 @@
>  #include "builtin.h"
>  #include "config.h"
> +#include "checkout.h"
>  #include "lockfile.h"
>  #include "parse-options.h"
>  #include "refs.h"
With this, and also ...
Show 8 quoted lines
> diff --git a/checkout.c b/checkout.c
> new file mode 100644
> index 0000000000..b0c744d37a
> --- /dev/null
> +++ b/checkout.c
> @@ -0,0 +1,42 @@
> +#include "cache.h"
> +#include "remote.h"

... with this, I sort of expected that builtin/checkout.c no longer has to include "remote.h" but can now rely on the common helpers in this new file to perform anything remote-related operation. But it seems that it is not the case (yet).

Just recording my observation for future reference, as we might also want to move report_tracking(), etc., to this new file in the future.

Previous: Thomas GummererNext: Thomas Gummerer
Message 15 of 36 in “make git worktree add dwim more”
  1. 0/4 make git worktree add dwim moreThomas Gummerer, Nov 22, 2017
  2. 4/4 worktree: make add <path> dwimThomas Gummerer, Nov 22, 2017
  3. Junio C HamanoNov 24, 2017
  4. Thomas GummererNov 25, 2017
  5. Paul SmithNov 25, 2017
  6. Thomas GummererNov 25, 2017
  7. Randall S. BeckerNov 25, 2017
  8. Thomas GummererNov 25, 2017
  9. Paul SmithNov 25, 2017
  10. Junio C HamanoNov 26, 2017
  11. Thomas GummererNov 26, 2017
  12. 3/4 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 22, 2017
  13. Junio C HamanoNov 24, 2017
  14. 1/4 checkout: factor out functions to new lib fileThomas Gummerer, Nov 22, 2017
  15. Junio C HamanoNov 24, 2017
  16. 2/4 worktree: add --[no-]track option to the add subcommandThomas Gummerer, Nov 22, 2017
  17. Junio C HamanoNov 24, 2017
  18. Thomas GummererNov 25, 2017
  19. 0/6 make git worktree add dwim moreThomas Gummerer, Nov 26, 2017
  20. 1/6 checkout: factor out functions to new lib fileThomas Gummerer, Nov 26, 2017
  21. 2/6 worktree: add can be created from any commit-ishThomas Gummerer, Nov 26, 2017
  22. 3/6 worktree: add --[no-]track option to the add subcommandThomas Gummerer, Nov 26, 2017
  23. 4/6 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 26, 2017
  24. 6/6 add worktree.guessRemote config optionThomas Gummerer, Nov 26, 2017
  25. Junio C HamanoNov 27, 2017
  26. Thomas GummererNov 27, 2017
  27. 5/6 worktree: add --guess-remote flag to add subcommandThomas Gummerer, Nov 26, 2017
  28. Junio C HamanoNov 27, 2017
  29. Thomas GummererNov 27, 2017
  30. 0/6 make git worktree add dwim moreThomas Gummerer, Nov 29, 2017
  31. 1/6 checkout: factor out functions to new lib fileThomas Gummerer, Nov 29, 2017
  32. 2/6 worktree: add can be created from any commit-ishThomas Gummerer, Nov 29, 2017
  33. 3/6 worktree: add --[no-]track option to the add subcommandThomas Gummerer, Nov 29, 2017
  34. 5/6 worktree: add --guess-remote flag to add subcommandThomas Gummerer, Nov 29, 2017
  35. 6/6 add worktree.guessRemote config optionThomas Gummerer, Nov 29, 2017
  36. 4/6 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 29, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.