git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Behavior of 'git fetch' for commit hashes
@ 2017-06-19 12:09 eero.aaltonen
  2017-06-19 15:50 ` Stefan Beller
  2017-06-19 17:49 ` Jonathan Tan
  0 siblings, 2 replies; 5+ messages in thread
From: eero.aaltonen @ 2017-06-19 12:09 UTC (permalink / raw)
  To: git

Hello,

I am seeing greatly different behavior for 'git fetch' commands on
version 2.7.4 and 2.13.1 when the argument to fetch is a commit hash.

I am working on a custom Continuous Integration (CI) system. The
projects have dependencies that are simply fetched as repositories to a
project subdirectory.

In order to prevent a race condition in updating branches, I want to
checkout the actual commit that was built in a previous job.

Environment
===========
Problem occurs with Git clients
- 2.7.4
- 2.13.1

and Git server
- Atlassian Bitbucket v4.14.3
- git version 2.12.0


The problem can be reproduced as follows, with
- <authoritativeUrl> = URL to primary repository
- <forkUrl> = URL to fork of the primary
- <sha1> commit hash in a recent branch

1. git clone <authoritativeUrl>
2. cd resulting_directory
3. git fetch <forkUrl> <sha1>

For version 2.7.4
=================
Git exits with exit code 1.

However, if I first do 'git fetch <branch>', then 'git fetch <sha1> will
also work

 * branch   <sha1> -> FETCH_HEAD

For version 2.13.3
==================
Git exits with exit code 128 and message
fatal: Couldn't find remote ref

However, the workaround for descbibed abot for git version 2.7.4 no
longer works. The result is always
fatal: Couldn't find remote ref

Desired result
==============
Commit is in .git/FETCH_HEAD and can be checked out.


I want to checkout a specific commit without creating any extra named
remotes in the local git clone.

Finally,
What is the expected behavior for 'git fetch' in this case?
Is there some other way I can achieve my goals?

-- 
Best regards,
Eero Aaltonen

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-20 11:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-19 12:09 Behavior of 'git fetch' for commit hashes eero.aaltonen
2017-06-19 15:50 ` Stefan Beller
2017-06-19 17:49 ` Jonathan Tan
2017-06-19 22:26   ` Jonathan Tan
2017-06-20 11:32     ` eero.aaltonen

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).