Skip to content

Commit 91774af

Browse files
mhaggergitster
authored andcommitted
refs: rename constant REF_NODEREF to REF_NO_DEREF
Even after working with this code for years, I still see this constant name as "ref node ref". Rename it to make it's meaning clearer. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5ac95fe commit 91774af

File tree

12 files changed

+40
-40
lines changed

12 files changed

+40
-40
lines changed

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ static void am_abort(struct am_state *state)
21512151
has_curr_head ? &curr_head : NULL, 0,
21522152
UPDATE_REFS_DIE_ON_ERR);
21532153
else if (curr_branch)
2154-
delete_ref(NULL, curr_branch, NULL, REF_NODEREF);
2154+
delete_ref(NULL, curr_branch, NULL, REF_NO_DEREF);
21552155

21562156
free(curr_branch);
21572157
am_destroy(state);

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
258258
}
259259

260260
if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,
261-
REF_NODEREF)) {
261+
REF_NO_DEREF)) {
262262
error(remote_branch
263263
? _("Error deleting remote-tracking branch '%s'")
264264
: _("Error deleting branch '%s'"),

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
665665
/* Nothing to do. */
666666
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
667667
update_ref(msg.buf, "HEAD", &new->commit->object.oid, NULL,
668-
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
668+
REF_NO_DEREF, UPDATE_REFS_DIE_ON_ERR);
669669
if (!opts->quiet) {
670670
if (old->path &&
671671
advice_detached_head && !opts->force_detach)

builtin/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,15 +689,15 @@ static void update_head(const struct ref *our, const struct ref *remote,
689689
} else if (our) {
690690
struct commit *c = lookup_commit_reference(&our->old_oid);
691691
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
692-
update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NODEREF,
692+
update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NO_DEREF,
693693
UPDATE_REFS_DIE_ON_ERR);
694694
} else if (remote) {
695695
/*
696696
* We know remote HEAD points to a non-branch, or
697697
* HEAD points to a branch but we don't know which one.
698698
* Detach HEAD in all these cases.
699699
*/
700-
update_ref(msg, "HEAD", &remote->old_oid, NULL, REF_NODEREF,
700+
update_ref(msg, "HEAD", &remote->old_oid, NULL, REF_NO_DEREF,
701701
UPDATE_REFS_DIE_ON_ERR);
702702
}
703703
}

builtin/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static int merge_abort(struct notes_merge_options *o)
686686

687687
if (delete_ref(NULL, "NOTES_MERGE_PARTIAL", NULL, 0))
688688
ret += error(_("failed to delete ref NOTES_MERGE_PARTIAL"));
689-
if (delete_ref(NULL, "NOTES_MERGE_REF", NULL, REF_NODEREF))
689+
if (delete_ref(NULL, "NOTES_MERGE_REF", NULL, REF_NO_DEREF))
690690
ret += error(_("failed to delete ref NOTES_MERGE_REF"));
691691
if (notes_merge_abort(o))
692692
ret += error(_("failed to remove 'git notes merge' worktree"));

builtin/remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static int mv(int argc, const char **argv)
693693
read_ref_full(item->string, RESOLVE_REF_READING, &oid, &flag);
694694
if (!(flag & REF_ISSYMREF))
695695
continue;
696-
if (delete_ref(NULL, item->string, NULL, REF_NODEREF))
696+
if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
697697
die(_("deleting '%s' failed"), item->string);
698698
}
699699
for (i = 0; i < remote_branches.nr; i++) {
@@ -788,7 +788,7 @@ static int rm(int argc, const char **argv)
788788
strbuf_release(&buf);
789789

790790
if (!result)
791-
result = delete_refs("remote: remove", &branches, REF_NODEREF);
791+
result = delete_refs("remote: remove", &branches, REF_NO_DEREF);
792792
string_list_clear(&branches, 0);
793793

794794
if (skipped.nr) {
@@ -1255,7 +1255,7 @@ static int set_head(int argc, const char **argv)
12551255
head_name = xstrdup(states.heads.items[0].string);
12561256
free_remote_ref_states(&states);
12571257
} else if (opt_d && !opt_a && argc == 1) {
1258-
if (delete_ref(NULL, buf.buf, NULL, REF_NODEREF))
1258+
if (delete_ref(NULL, buf.buf, NULL, REF_NO_DEREF))
12591259
result |= error(_("Could not delete %s"), buf.buf);
12601260
} else
12611261
usage_with_options(builtin_remote_sethead_usage, options);

builtin/symbolic-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
5858
die("Cannot delete %s, not a symbolic ref", argv[0]);
5959
if (!strcmp(argv[0], "HEAD"))
6060
die("deleting '%s' is not allowed", argv[0]);
61-
return delete_ref(NULL, argv[0], NULL, REF_NODEREF);
61+
return delete_ref(NULL, argv[0], NULL, REF_NO_DEREF);
6262
}
6363

6464
switch (argc) {

builtin/update-ref.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,
312312
static const char *parse_cmd_option(struct strbuf *input, const char *next)
313313
{
314314
if (!strncmp(next, "no-deref", 8) && next[8] == line_termination)
315-
update_flags |= REF_NODEREF;
315+
update_flags |= REF_NO_DEREF;
316316
else
317317
die("option unknown: %s", next);
318318
return next + 8;
@@ -427,7 +427,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
427427
}
428428

429429
if (no_deref)
430-
flags = REF_NODEREF;
430+
flags = REF_NO_DEREF;
431431
if (delete)
432432
/*
433433
* For purposes of backwards compatibility, we treat

refs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
476476
* transaction.
477477
*
478478
* flags -- flags affecting the update, passed to
479-
* update_ref_lock(). Possible flags: REF_NODEREF,
479+
* update_ref_lock(). Possible flags: REF_NO_DEREF,
480480
* REF_FORCE_CREATE_REFLOG. See those constants for more
481481
* information.
482482
*
@@ -504,7 +504,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
504504
* If this flag is not specified, then symbolic references are
505505
* dereferenced and the update is applied to the referent.
506506
*/
507-
#define REF_NODEREF (1 << 0)
507+
#define REF_NO_DEREF (1 << 0)
508508

509509
/*
510510
* Force the creation of a reflog for this reference, even if it
@@ -517,7 +517,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
517517
* ref_transaction_update() and friends:
518518
*/
519519
#define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \
520-
(REF_NODEREF | REF_FORCE_CREATE_REFLOG)
520+
(REF_NO_DEREF | REF_FORCE_CREATE_REFLOG)
521521

522522
/*
523523
* Add a reference update to transaction. `new_oid` is the value that

refs/files-backend.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
/*
1414
* This backend uses the following flags in `ref_update::flags` for
1515
* internal bookkeeping purposes. Their numerical values must not
16-
* conflict with REF_NODEREF, REF_FORCE_CREATE_REFLOG, REF_HAVE_NEW,
16+
* conflict with REF_NO_DEREF, REF_FORCE_CREATE_REFLOG, REF_HAVE_NEW,
1717
* REF_HAVE_OLD, or REF_ISPRUNING, which are also stored in
1818
* `ref_update::flags`.
1919
*/
2020

2121
/*
2222
* Used as a flag in ref_update::flags when a loose ref is being
23-
* pruned. This flag must only be used when REF_NODEREF is set.
23+
* pruned. This flag must only be used when REF_NO_DEREF is set.
2424
*/
2525
#define REF_ISPRUNING (1 << 4)
2626

@@ -1044,7 +1044,7 @@ static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)
10441044
goto cleanup;
10451045
ref_transaction_add_update(
10461046
transaction, r->name,
1047-
REF_NODEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_ISPRUNING,
1047+
REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_ISPRUNING,
10481048
&null_oid, &r->oid, NULL);
10491049
if (ref_transaction_commit(transaction, &err))
10501050
goto cleanup;
@@ -1133,7 +1133,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
11331133
*/
11341134
if (ref_transaction_update(transaction, iter->refname,
11351135
iter->oid, NULL,
1136-
REF_NODEREF, NULL, &err))
1136+
REF_NO_DEREF, NULL, &err))
11371137
die("failure preparing to create packed reference %s: %s",
11381138
iter->refname, err.buf);
11391139

@@ -1336,7 +1336,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
13361336
}
13371337

13381338
if (!copy && refs_delete_ref(&refs->base, logmsg, oldrefname,
1339-
&orig_oid, REF_NODEREF)) {
1339+
&orig_oid, REF_NO_DEREF)) {
13401340
error("unable to delete old %s", oldrefname);
13411341
goto rollback;
13421342
}
@@ -1352,7 +1352,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
13521352
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
13531353
&oid, NULL) &&
13541354
refs_delete_ref(&refs->base, NULL, newrefname,
1355-
NULL, REF_NODEREF)) {
1355+
NULL, REF_NO_DEREF)) {
13561356
if (errno == EISDIR) {
13571357
struct strbuf path = STRBUF_INIT;
13581358
int result;
@@ -1377,7 +1377,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
13771377
logmoved = log;
13781378

13791379
lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL,
1380-
REF_NODEREF, NULL, &err);
1380+
REF_NO_DEREF, NULL, &err);
13811381
if (!lock) {
13821382
if (copy)
13831383
error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf);
@@ -1400,7 +1400,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
14001400

14011401
rollback:
14021402
lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL,
1403-
REF_NODEREF, NULL, &err);
1403+
REF_NO_DEREF, NULL, &err);
14041404
if (!lock) {
14051405
error("unable to lock %s for rollback: %s", oldrefname, err.buf);
14061406
strbuf_release(&err);
@@ -1816,7 +1816,7 @@ static int files_create_symref(struct ref_store *ref_store,
18161816
int ret;
18171817

18181818
lock = lock_ref_oid_basic(refs, refname, NULL,
1819-
NULL, NULL, REF_NODEREF, NULL,
1819+
NULL, NULL, REF_NO_DEREF, NULL,
18201820
&err);
18211821
if (!lock) {
18221822
error("%s", err.buf);
@@ -2200,7 +2200,7 @@ static int split_head_update(struct ref_update *update,
22002200

22012201
new_update = ref_transaction_add_update(
22022202
transaction, "HEAD",
2203-
update->flags | REF_LOG_ONLY | REF_NODEREF,
2203+
update->flags | REF_LOG_ONLY | REF_NO_DEREF,
22042204
&update->new_oid, &update->old_oid,
22052205
update->msg);
22062206

@@ -2219,8 +2219,8 @@ static int split_head_update(struct ref_update *update,
22192219

22202220
/*
22212221
* update is for a symref that points at referent and doesn't have
2222-
* REF_NODEREF set. Split it into two updates:
2223-
* - The original update, but with REF_LOG_ONLY and REF_NODEREF set
2222+
* REF_NO_DEREF set. Split it into two updates:
2223+
* - The original update, but with REF_LOG_ONLY and REF_NO_DEREF set
22242224
* - A new, separate update for the referent reference
22252225
* Note that the new update will itself be subject to splitting when
22262226
* the iteration gets to it.
@@ -2275,7 +2275,7 @@ static int split_symref_update(struct files_ref_store *refs,
22752275
* doesn't need to check its old SHA-1 value, as that will be
22762276
* done when new_update is processed.
22772277
*/
2278-
update->flags |= REF_LOG_ONLY | REF_NODEREF;
2278+
update->flags |= REF_LOG_ONLY | REF_NO_DEREF;
22792279
update->flags &= ~REF_HAVE_OLD;
22802280

22812281
/*
@@ -2344,7 +2344,7 @@ static int check_old_oid(struct ref_update *update, struct object_id *oid,
23442344
* - Check that its old SHA-1 value (if specified) is correct, and in
23452345
* any case record it in update->lock->old_oid for later use when
23462346
* writing the reflog.
2347-
* - If it is a symref update without REF_NODEREF, split it up into a
2347+
* - If it is a symref update without REF_NO_DEREF, split it up into a
23482348
* REF_LOG_ONLY update of the symref and add a separate update for
23492349
* the referent to transaction.
23502350
* - If it is an update of head_ref, add a corresponding REF_LOG_ONLY
@@ -2392,7 +2392,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,
23922392
update->backend_data = lock;
23932393

23942394
if (update->type & REF_ISSYMREF) {
2395-
if (update->flags & REF_NODEREF) {
2395+
if (update->flags & REF_NO_DEREF) {
23962396
/*
23972397
* We won't be reading the referent as part of
23982398
* the transaction, so we have to read it here
@@ -2564,16 +2564,16 @@ static int files_transaction_prepare(struct ref_store *ref_store,
25642564
* split_symref_update() or split_head_update(), those
25652565
* functions will check that the new updates don't have the
25662566
* same refname as any existing ones.) Also fail if any of the
2567-
* updates use REF_ISPRUNING without REF_NODEREF.
2567+
* updates use REF_ISPRUNING without REF_NO_DEREF.
25682568
*/
25692569
for (i = 0; i < transaction->nr; i++) {
25702570
struct ref_update *update = transaction->updates[i];
25712571
struct string_list_item *item =
25722572
string_list_append(&affected_refnames, update->refname);
25732573

25742574
if ((update->flags & REF_ISPRUNING) &&
2575-
!(update->flags & REF_NODEREF))
2576-
BUG("REF_ISPRUNING set without REF_NODEREF");
2575+
!(update->flags & REF_NO_DEREF))
2576+
BUG("REF_ISPRUNING set without REF_NO_DEREF");
25772577

25782578
/*
25792579
* We store a pointer to update in item->util, but at
@@ -2651,7 +2651,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
26512651

26522652
ref_transaction_add_update(
26532653
packed_transaction, update->refname,
2654-
REF_HAVE_NEW | REF_NODEREF,
2654+
REF_HAVE_NEW | REF_NO_DEREF,
26552655
&update->new_oid, NULL,
26562656
NULL);
26572657
}
@@ -2995,7 +2995,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
29952995
* reference if --updateref was specified:
29962996
*/
29972997
lock = lock_ref_oid_basic(refs, refname, oid,
2998-
NULL, NULL, REF_NODEREF,
2998+
NULL, NULL, REF_NO_DEREF,
29992999
&type, &err);
30003000
if (!lock) {
30013001
error("cannot lock ref '%s': %s", refname, err.buf);

0 commit comments

Comments
 (0)