diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-02-26 18:10:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-26 18:10:25 -0800 |
commit | 65462776c2963b377968e580ace1590238bf79c1 (patch) | |
tree | 06c3b37bddbf5ddea8b78ddc59bd95459ba38882 /builtin | |
parent | cf258a9e4ef389277dfc2ddb0ec91fd13cead55f (diff) | |
parent | 7abc1869e552b80ea35923ae4315cb8bb0b47b64 (diff) | |
download | git-65462776c2963b377968e580ace1590238bf79c1.tar.gz |
Merge branch 'gt/at-is-synonym-for-head-in-add-patch'
Teach "git checkout -p" and friends that "@" is a synonym for
"HEAD".
* gt/at-is-synonym-for-head-in-add-patch:
add -p tests: remove PERL prerequisites
add-patch: classify '@' as a synonym for 'HEAD'
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/checkout.c | 4 | ||||
-rw-r--r-- | builtin/reset.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index a6e30931b5..067c251933 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1224,7 +1224,9 @@ static void setup_new_branch_info_and_source_tree( struct tree **source_tree = &opts->source_tree; struct object_id branch_rev; - new_branch_info->name = xstrdup(arg); + /* treat '@' as a shortcut for 'HEAD' */ + new_branch_info->name = !strcmp(arg, "@") ? xstrdup("HEAD") : + xstrdup(arg); setup_branch_path(new_branch_info); if (!check_refname_format(new_branch_info->path, 0) && diff --git a/builtin/reset.c b/builtin/reset.c index 8390bfe4c4..f0bf29a478 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -281,7 +281,9 @@ static void parse_args(struct pathspec *pathspec, verify_filename(prefix, argv[0], 1); } } - *rev_ret = rev; + + /* treat '@' as a shortcut for 'HEAD' */ + *rev_ret = !strcmp("@", rev) ? "HEAD" : rev; parse_pathspec(pathspec, 0, PATHSPEC_PREFER_FULL | |