Re: [PATCH v2] checkout: implement "-" shortcut name for last branch

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

 



Hi,

On Thu, 15 Jan 2009, Thomas Rast wrote:

> Johannes Schindelin wrote:
> > On Thu, 15 Jan 2009, Johannes Sixt wrote:
> > > You must make sure that commits referenced by LAST_HEAD are not
> > > garbage-collected. (I don't know if this happens anyway for symrefs in .git.)
> > 
> > Note: if you used reflogs for that feature, the garbage collection could 
> > not have killed the commit.  However, it is quite possible that the 
> > branch was deleted.
> 
> Suddenly I'm not so sure about either behaviour any more.
> 
> Consider:
> 
>   $ git commit -m initial
>   [master (root-commit)]: created 812c476: "initial"
>    1 files changed, 1 insertions(+), 0 deletions(-)
>    create mode 100644 foo
>   $ git checkout $(git rev-parse HEAD)
>   Note: moving to "812c476ca23e25efa7e4d7081153ba657a127d95" which isn't a local branch
>   If you want to create a new branch from this checkout, you may do so
>   (now or later) by using -b with the checkout command again. Example:
>     git checkout -b <new_branch_name>
>   HEAD is now at 812c476... initial
>   $ git branch -D master
>   Deleted branch master (812c476).
>   $ git for-each-ref
>   $ git reflog expire --expire=now --all
>   $ git prune --expire now
>   $ git show
>   fatal: bad object HEAD
>   $ git show 812c476
>   fatal: ambiguous argument '812c476': unknown revision or path not in the working tree.
>   Use '--' to separate paths from revisions
> 
> Oops.
> 
> Some quick RTFS shows that it indeed "only" cares about refs and
> reflogs.

Maybe something like this would help (completely untested, though the 
idea should be clear)?

-- snipsnap --
[PATCH] pack-objects --all: include HEAD, which could be detached

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
---
 builtin-pack-objects.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index cb51916..da55671 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -2219,6 +2219,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 						 rp_ac_alloc * sizeof(*rp_av));
 			}
 			rp_av[rp_ac++] = arg;
+			if (!strcmp("--all", arg)) {
+				ALLOC_GROW(rp_av, rp_ac + 1, rp_ac_alloc);
+				rp_av[rp_ac++] = "HEAD";
+			}
 			continue;
 		}
 		if (!strcmp("--thin", arg)) {
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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