summaryrefslogtreecommitdiff
path: root/remote.h
diff options
context:
space:
mode:
authorLibravatar Srinidhi Kaushik <shrinidhi.kaushik@gmail.com>2020-10-03 17:40:44 +0530
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-10-03 09:59:18 -0700
commit99a1f9ae10816c2527d7197a5dde714f980b712b (patch)
tree95c75afca2199d9e9531266c4d7d5390a7d6c6f2 /remote.h
parentMerge branch 'ds/in-merge-bases-many-optim-bug' into sk/force-if-includes (diff)
downloadtgif-99a1f9ae10816c2527d7197a5dde714f980b712b.tar.xz
push: add reflog check for "--force-if-includes"
Add a check to verify if the remote-tracking ref of the local branch is reachable from one of its "reflog" entries. The check iterates through the local ref's reflog to see if there is an entry for the remote-tracking ref and collecting any commits that are seen, into a list; the iteration stops if an entry in the reflog matches the remote ref or if the entry timestamp is older the latest entry of the remote ref's "reflog". If there wasn't an entry found for the remote ref, "in_merge_bases_many()" is called to check if it is reachable from the list of collected commits. When a local branch that is based on a remote ref, has been rewound and is to be force pushed on the remote, "--force-if-includes" runs a check that ensures any updates to the remote-tracking ref that may have happened (by push from another repository) in-between the time of the last update to the local branch (via "git-pull", for instance) and right before the time of push, have been integrated locally before allowing a forced update. If the new option is passed without specifying "--force-with-lease", or specified along with "--force-with-lease=<refname>:<expect>" it is a "no-op". Signed-off-by: Srinidhi Kaushik <shrinidhi.kaushik@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.h')
-rw-r--r--remote.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/remote.h b/remote.h
index eb62a47044..2d5391d281 100644
--- a/remote.h
+++ b/remote.h
@@ -107,12 +107,20 @@ struct ref {
struct object_id new_oid;
struct object_id old_oid_expect; /* used by expect-old */
char *symref;
+ char *tracking_ref;
unsigned int
force:1,
forced_update:1,
expect_old_sha1:1,
exact_oid:1,
- deletion:1;
+ deletion:1,
+ /* Need to check if local reflog reaches the remote tip. */
+ check_reachable:1,
+ /*
+ * Store the result of the check enabled by "check_reachable";
+ * implies the local reflog does not reach the remote tip.
+ */
+ unreachable:1;
enum {
REF_NOT_MATCHED = 0, /* initial value */
@@ -142,6 +150,7 @@ struct ref {
REF_STATUS_REJECT_NEEDS_FORCE,
REF_STATUS_REJECT_STALE,
REF_STATUS_REJECT_SHALLOW,
+ REF_STATUS_REJECT_REMOTE_UPDATED,
REF_STATUS_UPTODATE,
REF_STATUS_REMOTE_REJECT,
REF_STATUS_EXPECTING_REPORT,
@@ -341,6 +350,7 @@ struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map);
struct push_cas_option {
unsigned use_tracking_for_rest:1;
+ unsigned use_force_if_includes:1;
struct push_cas {
struct object_id expect;
unsigned use_tracking:1;