git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Mark Rushakoff <mark@influxdata.com>
To: git@vger.kernel.org
Subject: Possible to unshallow or deepen based on local objects?
Date: Fri, 26 Jul 2019 11:43:13 -0700	[thread overview]
Message-ID: <CALxJwdP70PpcJKFC3FRm5t58yjxz438WwYisuFwQsJ2oaXV_9A@mail.gmail.com> (raw)

I am building some CI tooling, and I am working with a large-ish repository, so
I am trying to start with a shallow clone of the repository and deepen it on
demand. I am finding it very difficult to correctly switch between fetch
--depth and fetch --deepen.

I am looking for a way to "recover" from a fetch --depth call that made my
history shallower than before. Ultimately, I may take a different approach to
just work around this altogether, but I thought I'd ask here first.

In particular, if there is history like this:

A --- B --- C --- D --- E --- F
       \                 \
         ---------------- G
And my shallow history includes D..F, then I believe I am limited in my options
for fetching G:

- If I do a plain fetch of G, or if I use --deepen, then I pull in A and all of
  its history, which I don't strictly need or want yet.
- If I know G's parent is B, and I fetch --depth=1, then (I think) I will see
  B, E, F, and G, effectively losing sight of D

As a more contrived example, suppose I have a shallow clone of a repository:

bash-3.2$ git clone --depth=4 -q git@github.com:git/git.git
bash-3.2$ cd git
bash-3.2$ git log --format='%h %d'
3034dab  (HEAD -> master, origin/master, origin/HEAD)
98e06de
352253a
4098130  (grafted)
7b974e3
df63c2e
75ce486  (grafted)
70b39fb  (grafted)
afc3bf6  (grafted)
bash-3.2$ cat .git/shallow
409813088ad55ae4a60f55412f6b5ba6a89d89e7
70b39fbede78313656e8a6bd9b38b238ab10db2f
75ce48674889df6a2bb493fb5d6bef0ef60ca7ae
afc3bf6eb13d9fc489b569164819cff44db8ac17

And then suppose I fetch with depth smaller than before:

bash-3.2$ git fetch --depth=1 -q
bash-3.2$ git log --format='%h %d'
3034dab  (grafted, HEAD -> master, origin/master, origin/HEAD)
bash-3.2$ cat .git/shallow
3034dab9ed6b11970a53099a7b3ca981f1461365
409813088ad55ae4a60f55412f6b5ba6a89d89e7
70b39fbede78313656e8a6bd9b38b238ab10db2f
75ce48674889df6a2bb493fb5d6bef0ef60ca7ae
afc3bf6eb13d9fc489b569164819cff44db8ac17

I can still see the commits I had before the --depth=1 fetch:

bash-3.2$ git log -1 --format=oneline 75ce486
75ce48674889df6a2bb493fb5d6bef0ef60ca7ae (grafted) Merge branch
'di/readme-markup-fix'

Short of looking through .git/shallow and removing each entry whose parents I
can resolve, is there a built-in command to "unshallow based on local objects"?
I have tried many web search terms, I have looked through the docs for many
low-level git commands, I have tried variations of "git fetch .", and I am
stumped.

             reply	other threads:[~2019-07-26 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 18:43 Mark Rushakoff [this message]
2019-08-08 22:17 ` Possible to unshallow or deepen based on local objects? Mark Rushakoff
2019-08-08 22:33   ` Junio C Hamano

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=CALxJwdP70PpcJKFC3FRm5t58yjxz438WwYisuFwQsJ2oaXV_9A@mail.gmail.com \
    --to=mark@influxdata.com \
    --cc=git@vger.kernel.org \
    /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).