Skip to content

updated git-remote documentation#6

Closed
jmil wants to merge 1 commit intogit:masterfrom
jmil:master
Closed

updated git-remote documentation#6
jmil wants to merge 1 commit intogit:masterfrom
jmil:master

Conversation

@jmil
Copy link

@jmil jmil commented Jan 12, 2011

fixed docs for git-remote. you now should 'git fetch REMOTENAME', because 'git fetch' is incomplete for some repos and won't work

because 'git fetch' is incomplete for some repos and won't work
jonseymour pushed a commit to jonseymour/git that referenced this pull request Apr 23, 2011
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster added a commit that referenced this pull request Apr 27, 2011
gitster added a commit that referenced this pull request Aug 24, 2011
jnareb pushed a commit to jnareb/git that referenced this pull request Sep 22, 2011
@gitster gitster closed this Sep 23, 2011
gitster added a commit that referenced this pull request Oct 18, 2011
gitster added a commit that referenced this pull request Dec 19, 2011
gitster added a commit that referenced this pull request Jan 27, 2012
gitster added a commit that referenced this pull request Feb 17, 2012
gitster added a commit that referenced this pull request Mar 14, 2012
gitster added a commit that referenced this pull request Apr 16, 2012
dscho referenced this pull request in dscho/git May 21, 2012
fix build: error: conflicting types for 'mingw_exec...
gitster added a commit that referenced this pull request May 23, 2012
gitster added a commit that referenced this pull request Jun 21, 2012
gitster added a commit that referenced this pull request Jul 22, 2012
gitster added a commit that referenced this pull request Aug 20, 2012
gitster added a commit that referenced this pull request Aug 21, 2012
gitster added a commit that referenced this pull request Sep 18, 2012
gitster added a commit that referenced this pull request Oct 19, 2012
gitster added a commit that referenced this pull request Nov 19, 2012
gitster added a commit that referenced this pull request Dec 21, 2012
gitster added a commit that referenced this pull request Jan 14, 2013
gitster added a commit that referenced this pull request Jan 15, 2013
Remove a lot of unused code from "git imap-send".

With a further comment fixup in patch #6, this seems ready for
'next'.
Expecting a reroll.

* mh/imap-send-shrinkage:
  imap-send.c: simplify logic in lf_to_crlf()
  imap-send.c: fold struct store into struct imap_store
  imap-send.c: remove unused field imap_store::uidvalidity
  imap-send.c: use struct imap_store instead of struct store
  imap-send.c: remove unused field imap_store::trashnc
  imap-send.c: remove namespace fields from struct imap
  imap-send.c: remove struct imap argument to parse_imap_list_l()
  imap-send.c: inline parse_imap_list() in parse_list()
  imap-send.c: remove some unused fields from struct store
  imap-send.c: remove struct message
  imap-send.c: remove struct store_conf
  iamp-send.c: remove unused struct imap_store_conf
  imap-send.c: remove struct msg_data
  imap-send.c: remove msg_data::flags, which was always zero
gitster added a commit that referenced this pull request Jan 17, 2013
Remove a lot of unused code from "git imap-send".

With a further comment fixup in patch #6, this seems ready for
'next'.
Expecting a reroll.

* mh/imap-send-shrinkage:
  imap-send.c: simplify logic in lf_to_crlf()
  imap-send.c: fold struct store into struct imap_store
  imap-send.c: remove unused field imap_store::uidvalidity
  imap-send.c: use struct imap_store instead of struct store
  imap-send.c: remove unused field imap_store::trashnc
  imap-send.c: remove namespace fields from struct imap
  imap-send.c: remove struct imap argument to parse_imap_list_l()
  imap-send.c: inline parse_imap_list() in parse_list()
  imap-send.c: remove some unused fields from struct store
  imap-send.c: remove struct message
  imap-send.c: remove struct store_conf
  iamp-send.c: remove unused struct imap_store_conf
  imap-send.c: remove struct msg_data
  imap-send.c: remove msg_data::flags, which was always zero
gitster added a commit that referenced this pull request Jan 18, 2013
Remove a lot of unused code from "git imap-send".

With a further comment fixup in patch #6, this seems ready for
'next'.
Expecting a reroll.

* mh/imap-send-shrinkage:
  imap-send.c: simplify logic in lf_to_crlf()
  imap-send.c: fold struct store into struct imap_store
  imap-send.c: remove unused field imap_store::uidvalidity
  imap-send.c: use struct imap_store instead of struct store
  imap-send.c: remove unused field imap_store::trashnc
  imap-send.c: remove namespace fields from struct imap
  imap-send.c: remove struct imap argument to parse_imap_list_l()
  imap-send.c: inline parse_imap_list() in parse_list()
  imap-send.c: remove some unused fields from struct store
  imap-send.c: remove struct message
  imap-send.c: remove struct store_conf
  iamp-send.c: remove unused struct imap_store_conf
  imap-send.c: remove struct msg_data
  imap-send.c: remove msg_data::flags, which was always zero
gitster added a commit that referenced this pull request Feb 14, 2013
gitster added a commit that referenced this pull request Mar 21, 2013
gitster added a commit that referenced this pull request Apr 22, 2013
gitster added a commit that referenced this pull request May 21, 2013
gitster added a commit that referenced this pull request Jun 18, 2013
gitster added a commit that referenced this pull request Jul 19, 2013
gitster added a commit that referenced this pull request Aug 27, 2013
gitster added a commit that referenced this pull request Sep 20, 2013
gitster added a commit that referenced this pull request Oct 25, 2013
gitster pushed a commit that referenced this pull request Dec 11, 2013
Suppose a fetch or push is requested between two shallow repositories
(with no history deepening or shortening). A pack that contains
necessary objects is transferred over together with .git/shallow of
the sender. The receiver has to determine whether it needs to update
.git/shallow if new refs needs new shallow comits.

The rule here is avoid updating .git/shallow by default. But we don't
want to waste the received pack. If the pack contains two refs, one
needs new shallow commits installed in .git/shallow and one does not,
we keep the latter and reject/warn about the former.

Even if .git/shallow update is allowed, we only add shallow commits
strictly necessary for the former ref (remember the sender can send
more shallow commits than necessary) and pay attention not to
accidentally cut the receiver history short (no history shortening is
asked for)

So the steps to figure out what ref need what new shallow commits are:

1. Split the sender shallow commit list into "ours" and "theirs" list
   by has_sha1_file. Those that exist in current repo in "ours", the
   remaining in "theirs".

2. Check the receiver .git/shallow, remove from "ours" the ones that
   also exist in .git/shallow.

3. Fetch the new pack. Either install or unpack it.

4. Do has_sha1_file on "theirs" list again. Drop the ones that fail
   has_sha1_file. Obviously the new pack does not need them.

5. If the pack is kept, remove from "ours" the ones that do not exist
   in the new pack.

6. Walk the new refs to answer the question "what shallow commits,
   both ours and theirs, are required in .git/shallow in order to add
   this ref?". Shallow commits not associated to any refs are removed
   from their respective list.

7. (*) Check reachability (from the current refs) of all remaining
   commits in "ours". Those reachable are removed. We do not want to
   cut any part of our (reachable) history. We only check up
   commits. True reachability test is done by
   check_everything_connected() at the end as usual.

8. Combine the final "ours" and "theirs" and add them all to
   .git/shallow. Install new refs. The case where some hook rejects
   some refs on a push is explained in more detail in the push
   patches.

Of these steps, #6 and #7 are expensive. Both require walking through
some commits, or in the worst case all commits. And we rather avoid
them in at least common case, where the transferred pack does not
contain any shallow commits that the sender advertises. Let's look at
each scenario:

1) the sender has longer history than the receiver

   All shallow commits from the sender will be put into "theirs" list
   at step 1 because none of them exists in current repo. In the
   common case, "theirs" becomes empty at step 4 and exit early.

2) the sender has shorter history than the receiver

   All shallow commits from the sender are likely in "ours" list at
   step 1. In the common case, if the new pack is kept, we could empty
   "ours" and exit early at step 5.

   If the pack is not kept, we hit the expensive step 6 then exit
   after "ours" is emptied. There'll be only a handful of objects to
   walk in fast-forward case. If it's forced update, we may need to
   walk to the bottom.

3) the sender has same .git/shallow as the receiver

   This is similar to case 2 except that "ours" should be emptied at
   step 2 and exit early.

A fetch after "clone --depth=X" is case 1. A fetch after "clone" (from
a shallow repo) is case 3. Luckily they're cheap for the common case.

A push from "clone --depth=X" falls into case 2, which is expensive.
Some more work may be done at the sender/client side to avoid more
work on the server side: if the transferred pack does not contain any
shallow commits, send-pack should not send any shallow commits to the
receive-pack, effectively turning it into a normal push and avoid all
steps.

This patch implements all steps except #3, already handled by
fetch-pack and receive-pack, #6 and #7, which has their own patch due
to their size.

(*) in previous versions step 7 was put before step 3. I reorder it so
    that the common case that keeps the pack does not need to walk
    commits at all. In future if we implement faster commit
    reachability check (maybe with the help of pack bitmaps or commit
    cache), step 7 could become cheap and be moved up before 6 again.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster added a commit that referenced this pull request Jan 29, 2014
gitster added a commit that referenced this pull request Feb 19, 2014
gitster added a commit that referenced this pull request Mar 25, 2014
gitster added a commit that referenced this pull request Apr 19, 2014
gitster added a commit that referenced this pull request Jun 26, 2014
gitster added a commit that referenced this pull request Jul 29, 2014
gitster added a commit that referenced this pull request Sep 24, 2014
gitster added a commit that referenced this pull request Oct 24, 2014
gitster added a commit that referenced this pull request Feb 22, 2015
gitster added a commit that referenced this pull request Mar 3, 2015
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitster added a commit that referenced this pull request Mar 3, 2015
* master:
  Post 2.3 cycle (batch #6)
gitster added a commit that referenced this pull request Mar 17, 2015
hazychill pushed a commit to hazychill/git that referenced this pull request May 10, 2015
ja-po: Add Japanese translations
gitster added a commit that referenced this pull request May 22, 2015
gitster added a commit that referenced this pull request Jun 24, 2015
gitster added a commit that referenced this pull request Jul 21, 2015
gitster added a commit that referenced this pull request Aug 31, 2015
gitster added a commit that referenced this pull request Sep 23, 2015
gitster added a commit that referenced this pull request Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants