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>
Michael Haggerty committed
Nov 5, 2017 at 09:42 UTC
91774afcc30c7e8ffdf7b3e587d52c340684364f
12 files changed
+40
-40
builtin/am.c
+1
-1
@@ -2151,7 +2151,7 @@ static void am_abort(struct am_state *state)
2151
has_curr_head ? &curr_head : NULL, 0,
2152
UPDATE_REFS_DIE_ON_ERR);
2153
else if (curr_branch)
2154
- delete_ref(NULL, curr_branch, NULL, REF_NODEREF);
2154
+ delete_ref(NULL, curr_branch, NULL, REF_NO_DEREF);
2155
2156
free(curr_branch);
2157
am_destroy(state);
builtin/branch.c
+1
-1
@@ -258,7 +258,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
258
}
259
260
if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,
261
- REF_NODEREF)) {
261
+ REF_NO_DEREF)) {
262
error(remote_branch
263
? _("Error deleting remote-tracking branch '%s'")
264
: _("Error deleting branch '%s'"),
builtin/checkout.c
+1
-1
@@ -665,7 +665,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
665
/* Nothing to do. */
666
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
667
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);
669
if (!opts->quiet) {
670
if (old->path &&
671
advice_detached_head && !opts->force_detach)
builtin/clone.c
+2
-2
@@ -689,7 +689,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
689
} else if (our) {
690
struct commit *c = lookup_commit_reference(&our->old_oid);
691
/* --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,
693
UPDATE_REFS_DIE_ON_ERR);
694
} else if (remote) {
695
/*
@@ -697,7 +697,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
697
* HEAD points to a branch but we don't know which one.
698
* Detach HEAD in all these cases.
699
*/
700
- update_ref(msg, "HEAD", &remote->old_oid, NULL, REF_NODEREF,
700
+ update_ref(msg, "HEAD", &remote->old_oid, NULL, REF_NO_DEREF,
701
UPDATE_REFS_DIE_ON_ERR);
702
}
703
}
builtin/notes.c
+1
-1
@@ -686,7 +686,7 @@ static int merge_abort(struct notes_merge_options *o)
686
687
if (delete_ref(NULL, "NOTES_MERGE_PARTIAL", NULL, 0))
688
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))
690
ret += error(_("failed to delete ref NOTES_MERGE_REF"));
691
if (notes_merge_abort(o))
692
ret += error(_("failed to remove 'git notes merge' worktree"));
builtin/remote.c
+3
-3
@@ -693,7 +693,7 @@ static int mv(int argc, const char **argv)
693
read_ref_full(item->string, RESOLVE_REF_READING, &oid, &flag);
694
if (!(flag & REF_ISSYMREF))
695
continue;
696
- if (delete_ref(NULL, item->string, NULL, REF_NODEREF))
696
+ if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
697
die(_("deleting '%s' failed"), item->string);
698
}
699
for (i = 0; i < remote_branches.nr; i++) {
@@ -788,7 +788,7 @@ static int rm(int argc, const char **argv)
788
strbuf_release(&buf);
789
790
if (!result)
791
- result = delete_refs("remote: remove", &branches, REF_NODEREF);
791
+ result = delete_refs("remote: remove", &branches, REF_NO_DEREF);
792
string_list_clear(&branches, 0);
793
794
if (skipped.nr) {
@@ -1255,7 +1255,7 @@ static int set_head(int argc, const char **argv)
1255
head_name = xstrdup(states.heads.items[0].string);
1256
free_remote_ref_states(&states);
1257
} 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))
1259
result |= error(_("Could not delete %s"), buf.buf);
1260
} else
1261
usage_with_options(builtin_remote_sethead_usage, options);
builtin/symbolic-ref.c
+1
-1
@@ -58,7 +58,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
58
die("Cannot delete %s, not a symbolic ref", argv[0]);
59
if (!strcmp(argv[0], "HEAD"))
60
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);
62
}
63
64
switch (argc) {
builtin/update-ref.c
+2
-2
@@ -312,7 +312,7 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction,
312
static const char *parse_cmd_option(struct strbuf *input, const char *next)
313
{
314
if (!strncmp(next, "no-deref", 8) && next[8] == line_termination)
315
- update_flags |= REF_NODEREF;
315
+ update_flags |= REF_NO_DEREF;
316
else
317
die("option unknown: %s", next);
318
return next + 8;
@@ -427,7 +427,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
427
}
428
429
if (no_deref)
430
- flags = REF_NODEREF;
430
+ flags = REF_NO_DEREF;
431
if (delete)
432
/*
433
* For purposes of backwards compatibility, we treat
refs.h
+3
-3
@@ -476,7 +476,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
476
* transaction.
477
*
478
* flags -- flags affecting the update, passed to
479
- * update_ref_lock(). Possible flags: REF_NODEREF,
479
+ * update_ref_lock(). Possible flags: REF_NO_DEREF,
480
* REF_FORCE_CREATE_REFLOG. See those constants for more
481
* information.
482
*
@@ -504,7 +504,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
504
* If this flag is not specified, then symbolic references are
505
* dereferenced and the update is applied to the referent.
506
*/
507
-#define REF_NODEREF (1 << 0)
507
+#define REF_NO_DEREF (1 << 0)
508
509
/*
510
* 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);
517
* ref_transaction_update() and friends:
518
*/
519
#define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \
520
- (REF_NODEREF | REF_FORCE_CREATE_REFLOG)
520
+ (REF_NO_DEREF | REF_FORCE_CREATE_REFLOG)
521
522
/*
523
* Add a reference update to transaction. `new_oid` is the value that
refs/files-backend.c
+20
-20
@@ -13,14 +13,14 @@
13
/*
14
* This backend uses the following flags in `ref_update::flags` for
15
* 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,
17
* REF_HAVE_OLD, or REF_ISPRUNING, which are also stored in
18
* `ref_update::flags`.
19
*/
20
21
/*
22
* 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.
24
*/
25
#define REF_ISPRUNING (1 << 4)
26
@@ -1044,7 +1044,7 @@ static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)
1044
goto cleanup;
1045
ref_transaction_add_update(
1046
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,
1048
&null_oid, &r->oid, NULL);
1049
if (ref_transaction_commit(transaction, &err))
1050
goto cleanup;
@@ -1133,7 +1133,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
1133
*/
1134
if (ref_transaction_update(transaction, iter->refname,
1135
iter->oid, NULL,
1136
- REF_NODEREF, NULL, &err))
1136
+ REF_NO_DEREF, NULL, &err))
1137
die("failure preparing to create packed reference %s: %s",
1138
iter->refname, err.buf);
1139
@@ -1336,7 +1336,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
1336
}
1337
1338
if (!copy && refs_delete_ref(&refs->base, logmsg, oldrefname,
1339
- &orig_oid, REF_NODEREF)) {
1339
+ &orig_oid, REF_NO_DEREF)) {
1340
error("unable to delete old %s", oldrefname);
1341
goto rollback;
1342
}
@@ -1352,7 +1352,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
1352
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
1353
&oid, NULL) &&
1354
refs_delete_ref(&refs->base, NULL, newrefname,
1355
- NULL, REF_NODEREF)) {
1355
+ NULL, REF_NO_DEREF)) {
1356
if (errno == EISDIR) {
1357
struct strbuf path = STRBUF_INIT;
1358
int result;
@@ -1377,7 +1377,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
1377
logmoved = log;
1378
1379
lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL,
1380
- REF_NODEREF, NULL, &err);
1380
+ REF_NO_DEREF, NULL, &err);
1381
if (!lock) {
1382
if (copy)
1383
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,
1400
1401
rollback:
1402
lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL,
1403
- REF_NODEREF, NULL, &err);
1403
+ REF_NO_DEREF, NULL, &err);
1404
if (!lock) {
1405
error("unable to lock %s for rollback: %s", oldrefname, err.buf);
1406
strbuf_release(&err);
@@ -1816,7 +1816,7 @@ static int files_create_symref(struct ref_store *ref_store,
1816
int ret;
1817
1818
lock = lock_ref_oid_basic(refs, refname, NULL,
1819
- NULL, NULL, REF_NODEREF, NULL,
1819
+ NULL, NULL, REF_NO_DEREF, NULL,
1820
&err);
1821
if (!lock) {
1822
error("%s", err.buf);
@@ -2200,7 +2200,7 @@ static int split_head_update(struct ref_update *update,
2200
2201
new_update = ref_transaction_add_update(
2202
transaction, "HEAD",
2203
- update->flags | REF_LOG_ONLY | REF_NODEREF,
2203
+ update->flags | REF_LOG_ONLY | REF_NO_DEREF,
2204
&update->new_oid, &update->old_oid,
2205
update->msg);
2206
@@ -2219,8 +2219,8 @@ static int split_head_update(struct ref_update *update,
2219
2220
/*
2221
* 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
2224
* - A new, separate update for the referent reference
2225
* Note that the new update will itself be subject to splitting when
2226
* the iteration gets to it.
@@ -2275,7 +2275,7 @@ static int split_symref_update(struct files_ref_store *refs,
2275
* doesn't need to check its old SHA-1 value, as that will be
2276
* done when new_update is processed.
2277
*/
2278
- update->flags |= REF_LOG_ONLY | REF_NODEREF;
2278
+ update->flags |= REF_LOG_ONLY | REF_NO_DEREF;
2279
update->flags &= ~REF_HAVE_OLD;
2280
2281
/*
@@ -2344,7 +2344,7 @@ static int check_old_oid(struct ref_update *update, struct object_id *oid,
2344
* - Check that its old SHA-1 value (if specified) is correct, and in
2345
* any case record it in update->lock->old_oid for later use when
2346
* 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
2348
* REF_LOG_ONLY update of the symref and add a separate update for
2349
* the referent to transaction.
2350
* - 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,
2392
update->backend_data = lock;
2393
2394
if (update->type & REF_ISSYMREF) {
2395
- if (update->flags & REF_NODEREF) {
2395
+ if (update->flags & REF_NO_DEREF) {
2396
/*
2397
* We won't be reading the referent as part of
2398
* the transaction, so we have to read it here
@@ -2564,7 +2564,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2564
* split_symref_update() or split_head_update(), those
2565
* functions will check that the new updates don't have the
2566
* 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.
2568
*/
2569
for (i = 0; i < transaction->nr; i++) {
2570
struct ref_update *update = transaction->updates[i];
@@ -2572,8 +2572,8 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2572
string_list_append(&affected_refnames, update->refname);
2573
2574
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");
2577
2578
/*
2579
* 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,
2651
2652
ref_transaction_add_update(
2653
packed_transaction, update->refname,
2654
- REF_HAVE_NEW | REF_NODEREF,
2654
+ REF_HAVE_NEW | REF_NO_DEREF,
2655
&update->new_oid, NULL,
2656
NULL);
2657
}
@@ -2995,7 +2995,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
2995
* reference if --updateref was specified:
2996
*/
2997
lock = lock_ref_oid_basic(refs, refname, oid,
2998
- NULL, NULL, REF_NODEREF,
2998
+ NULL, NULL, REF_NO_DEREF,
2999
&type, &err);
3000
if (!lock) {
3001
error("cannot lock ref '%s': %s", refname, err.buf);
refs/refs-internal.h
+2
-2
@@ -9,7 +9,7 @@
9
10
/*
11
* The following flags can appear in `ref_update::flags`. Their
12
- * numerical values must not conflict with those of REF_NODEREF and
12
+ * numerical values must not conflict with those of REF_NO_DEREF and
13
* REF_FORCE_CREATE_REFLOG, which are also stored in
14
* `ref_update::flags`.
15
*/
@@ -119,7 +119,7 @@ struct ref_update {
119
struct object_id old_oid;
120
121
/*
122
- * One or more of REF_NODEREF, REF_FORCE_CREATE_REFLOG,
122
+ * One or more of REF_NO_DEREF, REF_FORCE_CREATE_REFLOG,
123
* REF_HAVE_NEW, REF_HAVE_OLD, or backend-specific flags.
124
*/
125
unsigned int flags;
sequencer.c
+3
-3
@@ -1116,11 +1116,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1116
*/
1117
if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) &&
1118
update_ref(NULL, "CHERRY_PICK_HEAD", &commit->object.oid, NULL,
1119
- REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))
1119
+ REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR))
1120
res = -1;
1121
if (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1) &&
1122
update_ref(NULL, "REVERT_HEAD", &commit->object.oid, NULL,
1123
- REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))
1123
+ REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR))
1124
res = -1;
1125
1126
if (res) {
@@ -2125,7 +2125,7 @@ cleanup_head_ref:
2125
msg = reflog_message(opts, "finish", "%s onto %s",
2126
head_ref.buf, buf.buf);
2127
if (update_ref(msg, head_ref.buf, &head, &orig,
2128
- REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {
2128
+ REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
2129
res = error(_("could not update %s"),
2130
head_ref.buf);
2131
goto cleanup_head_ref;