Git cannot create shallow-since locally

大兔子大兔子 提交于 2020-01-23 06:19:53

问题


I am trying to create a --shallow-since working clone from a local bare clone but it keeps pulling everything. --depth=N works fine.

I'm thinking the issue is I'm using the wrong format? I've tried searching but no where does it explicitly say what format < date > is supposed to be for --shallow-since=< date >.


回答1:


Format is YYYY-MM-DD

See above comment for what confused me and how that confusion was resolved.




回答2:


While the date format is indeed, for instance, YYYY-MM-DD, "git fetch --shallow-since=<cutoff>" had a problem:

If you specify a cut-off point that is newer than the existing history, it used to end up grabbing the entire history.
Such a request now errors out with Git 2.19 (Q3 2018).

See commit e34de73 (26 May 2018) by Nguyễn Thái Ngọc Duy (pclouds).
(Merged by Junio C Hamano -- gitster -- in commit 208ee59, 25 Jun 2018)

upload-pack: reject shallow requests that would return nothing

Shallow clones with --shallow-since or --shalow-exclude work by running rev-list to get all reachable commits, then draw a boundary between reachable and unreachable and send "shallow" requests based on that.

The code does miss one corner case: if rev-list returns nothing, we'll have no border and we'll send no shallow requests back to the client (i.e. no history cuts).
This essentially means a full clone (or a full branch if the client requests just one branch).
One example is the oldest commit is older than what is specified by --shallow-since.

To avoid this, if rev-list returns nothing, we abort the clone/fetch.
The user could adjust their request (e.g. --shallow-since further back in the past) and retry.

Another possible option for this case is to fall back to a default depth (like depth 1).
But I don't like too much magic that way because we may return something unexpected to the user. If they request "history since 2008" and we return a single depth at 2000, that might break stuff for them.
It is better to tell them that something is wrong and let them take the best course of action.



来源:https://stackoverflow.com/questions/43879184/git-cannot-create-shallow-since-locally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!