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

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

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Nov 14, 2017, 08:46 UTC
Message-ID
<20171114084607.GB12097@hank>
In-Reply-To
<xmqq7euuc32z.fsf@gitster.mtv.corp.google.com>
On 11/13, Junio C Hamano wrote:
Show 30 quoted lines
> Thomas Gummerer <t.gummerer@gmail.com> 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@gmail.com>
> > ---
> >
> > 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.
Makes sense, let me keep it as a new file then.
Show 32 quoted lines
> > 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".
Ah I forgot about that.  Will fix, thanks!
Previous: Junio C HamanoNext: Thomas Gummerer
Message 12 of 28 in “checkout: factor out functions to new lib file”
  1. 1/2 checkout: factor out functions to new lib fileThomas Gummerer, Nov 12, 2017
  2. 2/2 worktree: make add dwimThomas Gummerer, Nov 12, 2017
  3. Junio C HamanoNov 13, 2017
  4. Thomas GummererNov 14, 2017
  5. Eric SunshineNov 14, 2017
  6. Eric SunshineNov 14, 2017
  7. Thomas GummererNov 15, 2017
  8. Thomas GummererNov 18, 2017
  9. Thomas GummererNov 15, 2017
  10. Eric SunshineNov 15, 2017
  11. Junio C HamanoNov 13, 2017
  12. Thomas GummererNov 14, 2017
  13. 1/3 checkout: factor out functions to new lib fileThomas Gummerer, Nov 18, 2017
  14. 2/3 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 18, 2017
  15. Thomas GummererNov 18, 2017
  16. 3/3 worktree: make add <path> dwimThomas Gummerer, Nov 18, 2017
  17. 0/3 make git worktree add dwim moreThomas Gummerer, Nov 18, 2017
  18. 2/3 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 18, 2017
  19. Eric SunshineNov 19, 2017
  20. Thomas GummererNov 19, 2017
  21. 1/3 checkout: factor out functions to new lib fileThomas Gummerer, Nov 18, 2017
  22. 3/3 worktree: make add <path> dwimThomas Gummerer, Nov 18, 2017
  23. Eric SunshineNov 19, 2017
  24. Eric SunshineNov 19, 2017
  25. Junio C HamanoNov 20, 2017
  26. Thomas GummererNov 21, 2017
  27. Junio C HamanoNov 22, 2017
  28. Thomas GummererNov 22, 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.