[PATCH 2/2] checkout: do not write full sha1 to reflog
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Jun 15, 2013, 17:38 UTC
- Message-ID
- <1371317906-3991-3-git-send-email-artagnon@gmail.com>
- In-Reply-To
- <1371317906-3991-1-git-send-email-artagnon@gmail.com>
A snippet from a typical git session may look like this:
$ git checkout @~3 ... $ git checkout -
The reflog entries corresponding to the two checkouts look like:
f855138: checkout: moving from bdff0e3a374617dce784f801b97500d9ba2e4705 to co-reflog bdff0e3: checkout: moving from co-reflog to HEAD~3
There is no need to write the full SHA-1 to the user-visible reflog; use find_unique_abbrev() to shorten the first line like:
f855138: checkout: moving from bdff0e3 to co-reflog
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- builtin/checkout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c index f5b50e5..41b1929 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -619,7 +619,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts, old_desc = old->name; if (!old_desc && old->commit) - old_desc = sha1_to_hex(old->commit->object.sha1); + old_desc = find_unique_abbrev(old->commit->object.sha1, DEFAULT_ABBREV); strbuf_addf(&msg, "checkout: moving from %s to %s", old_desc ? old_desc : "(invalid)", new->name);
-- 1.8.3.1.438.g96d34e8