From: David Turner <dturner@twopensource.com>
To: git@vger.kernel.org, mhagger@alum.mit.edu
Cc: David Turner <dturner@twopensource.com>
Subject: [PATCH 9/9] refs: forbid pseudoref updates through ref update API
Date: Fri, 24 Jul 2015 00:45:29 -0400 [thread overview]
Message-ID: <1437713129-19373-10-git-send-email-dturner@twopensource.com> (raw)
In-Reply-To: <1437713129-19373-1-git-send-email-dturner@twopensource.com>
It is now forbidden to update pseudorefs through the ref update
framework.
Because of the pseudoref update rules change, test cases that used git
update-ref on a pseudoref now operate on plain refs.
Signed-off-by: David Turner <dturner@twopensource.com>
---
bisect.c | 2 +-
refs.c | 2 ++
t/t1400-update-ref.sh | 24 ++++++++++++------------
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/bisect.c b/bisect.c
index 3a9fd63..47cc778 100644
--- a/bisect.c
+++ b/bisect.c
@@ -969,7 +969,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
if (!hashcmp(bisect_rev, current_bad_oid->hash)) {
exit_if_skipped_commits(tried, current_bad_oid);
- printf("%s is the first %s commit\n", bisect_rev_hex,
+ printf("%s is the first %s commit\n", sha1_to_hex(bisect_rev),
term_bad);
show_diff_tree(prefix, revs.commits->item);
/* This means the bisection process succeeded. */
diff --git a/refs.c b/refs.c
index efa84e3..f8dc877 100644
--- a/refs.c
+++ b/refs.c
@@ -3902,6 +3902,8 @@ int ref_transaction_update(struct ref_transaction *transaction,
struct ref_update *update;
assert(err);
+ if (is_pseudoref(refname))
+ return error(_("BUG: Cannot update pseudorefs (all-caps files in .git) through the refs API"));
if (transaction->state != REF_TRANSACTION_OPEN)
die("BUG: update called for transaction that is not open");
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 0038f28..b05657c 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -608,13 +608,13 @@ test_expect_success 'stdin delete ref fails with zero old value' '
'
test_expect_success 'stdin update symref works option no-deref' '
- git symbolic-ref TESTSYMREF $b &&
+ git symbolic-ref refs/TESTSYMREF $b &&
cat >stdin <<-EOF &&
option no-deref
- update TESTSYMREF $a $b
+ update refs/TESTSYMREF $a $b
EOF
git update-ref --stdin <stdin &&
- git rev-parse TESTSYMREF >expect &&
+ git rev-parse refs/TESTSYMREF >expect &&
git rev-parse $a >actual &&
test_cmp expect actual &&
git rev-parse $m~1 >expect &&
@@ -623,13 +623,13 @@ test_expect_success 'stdin update symref works option no-deref' '
'
test_expect_success 'stdin delete symref works option no-deref' '
- git symbolic-ref TESTSYMREF $b &&
+ git symbolic-ref refs/TESTSYMREF $b &&
cat >stdin <<-EOF &&
option no-deref
- delete TESTSYMREF $b
+ delete refs/TESTSYMREF $b
EOF
git update-ref --stdin <stdin &&
- test_must_fail git rev-parse --verify -q TESTSYMREF &&
+ test_must_fail git rev-parse --verify -q refs/TESTSYMREF &&
git rev-parse $m~1 >expect &&
git rev-parse $b >actual &&
test_cmp expect actual
@@ -983,10 +983,10 @@ test_expect_success 'stdin -z delete ref fails with zero old value' '
'
test_expect_success 'stdin -z update symref works option no-deref' '
- git symbolic-ref TESTSYMREF $b &&
- printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin &&
+ git symbolic-ref refs/TESTSYMREF $b &&
+ printf $F "option no-deref" "update refs/TESTSYMREF" "$a" "$b" >stdin &&
git update-ref -z --stdin <stdin &&
- git rev-parse TESTSYMREF >expect &&
+ git rev-parse refs/TESTSYMREF >expect &&
git rev-parse $a >actual &&
test_cmp expect actual &&
git rev-parse $m~1 >expect &&
@@ -995,10 +995,10 @@ test_expect_success 'stdin -z update symref works option no-deref' '
'
test_expect_success 'stdin -z delete symref works option no-deref' '
- git symbolic-ref TESTSYMREF $b &&
- printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin &&
+ git symbolic-ref refs/TESTSYMREF $b &&
+ printf $F "option no-deref" "delete refs/TESTSYMREF" "$b" >stdin &&
git update-ref -z --stdin <stdin &&
- test_must_fail git rev-parse --verify -q TESTSYMREF &&
+ test_must_fail git rev-parse --verify -q refs/TESTSYMREF &&
git rev-parse $m~1 >expect &&
git rev-parse $b >actual &&
test_cmp expect actual
--
2.0.4.315.gad8727a-twtrsrc
next prev parent reply other threads:[~2015-07-24 4:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-24 4:45 [PATCH/RFC 0/9] Pseudorefs David Turner
2015-07-24 4:45 ` [PATCH 1/9] refs: Introduce pseudoref and per-worktree ref concepts David Turner
2015-07-24 7:34 ` Eric Sunshine
2015-07-24 19:20 ` Junio C Hamano
2015-07-24 20:13 ` David Turner
2015-07-24 20:44 ` Junio C Hamano
2015-07-24 19:52 ` Philip Oakley
2015-07-24 20:14 ` David Turner
2015-07-24 4:45 ` [PATCH 2/9] notes: replace pseudorefs with real refs David Turner
2015-07-24 4:45 ` [PATCH 3/9] bisect: do not use update-ref for BISECT_HEAD David Turner
2015-07-24 4:45 ` [PATCH 4/9] tests: treat FETCH_HEAD as a pseudoref David Turner
2015-07-24 4:45 ` [PATCH 5/9] tests: use --create-reflog option to git update-ref David Turner
2015-07-24 4:45 ` [PATCH 6/9] pseudorefs: create and use pseudoref update and delete functions David Turner
2015-07-24 19:25 ` Junio C Hamano
2015-07-24 20:17 ` David Turner
2015-07-24 20:53 ` Junio C Hamano
2015-07-24 4:45 ` [PATCH 7/9] am/rebase: update pseudorefs by writing files David Turner
2015-07-24 4:45 ` [PATCH 8/9] rebase: use write_pseudoref David Turner
2015-07-24 4:45 ` David Turner [this message]
2015-08-02 22:48 ` [PATCH/RFC 0/9] Pseudorefs Michael Haggerty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437713129-19373-10-git-send-email-dturner@twopensource.com \
--to=dturner@twopensource.com \
--cc=git@vger.kernel.org \
--cc=mhagger@alum.mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).