[PATCH 0/2] git checkout: one bugfix and one cosmetic change

STALE3736d

7 messages, 4 authors, 2016-06-15 · open the first message on its own page

[PATCH 0/2] git checkout: one bugfix and one cosmetic change

From: Kjetil Barvik <hidden>
Date: 2016-06-15 22:46:23

Just one small bugfix patch, and one small cosmetic change.

By the way, I wonder how often the list of 'Primary Authors' and
'Contributors' on the webpage http://git-scm.com/about is updated.
Should'nt it be updated when a new release, like v1.6.2, is made?

Kjetil Barvik (2):
  checkout bugfix: use stat.mtime instead of stat.ctime in two places
  make the ST_{C,M}TIME_NSEC macros more function like

[PATCH 2/2] make the ST_{C,M}TIME_NSEC macros more function like

From: Kjetil Barvik <hidden>
Date: 2016-06-15 22:46:23

Make the macros take a pointer to a 'struct stat'. This is so that it
should be easier to understand what is going on, and that the macros
can later be implemented as a inline function if we want to.

Impact: cosmetic change

Signed-off-by: Kjetil Barvik <redacted>
---
 builtin-fetch-pack.c |    4 ++--
 git-compat-util.h    |    8 ++++----
 read-cache.c         |   12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index d571253..0cd50f3 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -800,13 +800,13 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
 		int fd;
 
 		mtime.sec = st.st_mtime;
-		mtime.nsec = ST_MTIME_NSEC(st);
+		mtime.nsec = ST_MTIME_NSEC(&st);
 		if (stat(shallow, &st)) {
 			if (mtime.sec)
 				die("shallow file was removed during fetch");
 		} else if (st.st_mtime != mtime.sec
 #ifdef USE_NSEC
-				|| ST_MTIME_NSEC(st) != mtime.nsec
+				|| ST_MTIME_NSEC(&st) != mtime.nsec
 #endif
 			  )
 			die("shallow file was changed during fetch");
diff --git a/git-compat-util.h b/git-compat-util.h
index 1906253..4a633be 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -394,11 +394,11 @@ void git_qsort(void *base, size_t nmemb, size_t size,
 #define ST_MTIME_NSEC(st) 0
 #else
 #ifdef USE_ST_TIMESPEC
-#define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctimespec.tv_nsec))
-#define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtimespec.tv_nsec))
+#define ST_CTIME_NSEC(st) ((unsigned int)((st)->st_ctimespec.tv_nsec))
+#define ST_MTIME_NSEC(st) ((unsigned int)((st)->st_mtimespec.tv_nsec))
 #else
-#define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctim.tv_nsec))
-#define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtim.tv_nsec))
+#define ST_CTIME_NSEC(st) ((unsigned int)((st)->st_ctim.tv_nsec))
+#define ST_MTIME_NSEC(st) ((unsigned int)((st)->st_mtim.tv_nsec))
 #endif
 #endif
 
diff --git a/read-cache.c b/read-cache.c
index 3f58711..cff85e3 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -69,8 +69,8 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
 {
 	ce->ce_ctime.sec = (unsigned int)st->st_ctime;
 	ce->ce_mtime.sec = (unsigned int)st->st_mtime;
-	ce->ce_ctime.nsec = ST_CTIME_NSEC(*st);
-	ce->ce_mtime.nsec = ST_MTIME_NSEC(*st);
+	ce->ce_ctime.nsec = ST_CTIME_NSEC(st);
+	ce->ce_mtime.nsec = ST_MTIME_NSEC(st);
 	ce->ce_dev = st->st_dev;
 	ce->ce_ino = st->st_ino;
 	ce->ce_uid = st->st_uid;
@@ -204,9 +204,9 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 		changed |= CTIME_CHANGED;
 
 #ifdef USE_NSEC
-	if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
+	if (ce->ce_mtime.nsec != ST_MTIME_NSEC(st))
 		changed |= MTIME_CHANGED;
-	if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
+	if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(st))
 		changed |= CTIME_CHANGED;
 #endif
 
@@ -1299,7 +1299,7 @@ int read_index_from(struct index_state *istate, const char *path)
 		dst_offset += ce_size(ce);
 	}
 	istate->timestamp.sec = st.st_mtime;
-	istate->timestamp.nsec = ST_MTIME_NSEC(st);
+	istate->timestamp.nsec = ST_MTIME_NSEC(&st);
 
 	while (src_offset <= mmap_size - 20 - 8) {
 		/* After an array of active_nr index entries,
@@ -1564,7 +1564,7 @@ int write_index(struct index_state *istate, int newfd)
 	if (ce_flush(&c, newfd) || fstat(newfd, &st))
 		return -1;
 	istate->timestamp.sec = (unsigned int)st.st_mtime;
-	istate->timestamp.nsec = ST_MTIME_NSEC(st);
+	istate->timestamp.nsec = ST_MTIME_NSEC(&st);
 	return 0;
 }
 
-- 
1.6.2.GIT

[PATCH 1/2] checkout bugfix: use stat.mtime instead of stat.ctime in two places

From: Kjetil Barvik <hidden>
Date: 2016-06-15 22:46:23

Commit e1afca4fd "write_index(): update index_state->timestamp after
flushing to disk" on 2009-02-23 used stat.ctime to record the
timestamp of the index-file.  This is wrong, so fix this and use the
correct stat.mtime timestamp instead.

Commit 110c46a909 "Not all systems use st_[cm]tim field for ns
resolution file timestamp" on 2009-03-08, has a similar bug for the
builtin-fetch-pack.c file.

Signed-off-by: Kjetil Barvik <redacted>
---
 builtin-fetch-pack.c |    2 +-
 read-cache.c         |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 0b1a356..d571253 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -806,7 +806,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
 				die("shallow file was removed during fetch");
 		} else if (st.st_mtime != mtime.sec
 #ifdef USE_NSEC
-				|| ST_CTIME_NSEC(st) != mtime.nsec
+				|| ST_MTIME_NSEC(st) != mtime.nsec
 #endif
 			  )
 			die("shallow file was changed during fetch");
diff --git a/read-cache.c b/read-cache.c
index 7f74c8d..3f58711 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1563,8 +1563,8 @@ int write_index(struct index_state *istate, int newfd)
 
 	if (ce_flush(&c, newfd) || fstat(newfd, &st))
 		return -1;
-	istate->timestamp.sec = (unsigned int)st.st_ctime;
-	istate->timestamp.nsec = ST_CTIME_NSEC(st);
+	istate->timestamp.sec = (unsigned int)st.st_mtime;
+	istate->timestamp.nsec = ST_MTIME_NSEC(st);
 	return 0;
 }
 
-- 
1.6.2.GIT

Re: [PATCH 0/2] git checkout: one bugfix and one cosmetic change

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:46:24

Kjetil Barvik venit, vidit, dixit 15.03.2009 12:38:
Just one small bugfix patch, and one small cosmetic change.

By the way, I wonder how often the list of 'Primary Authors' and
'Contributors' on the webpage http://git-scm.com/about is updated.
Should'nt it be updated when a new release, like v1.6.2, is made?
Assuming it looks at all non-merge commits on master, I can tell you it
has been updated after Dec 18 09:55:53 2008 -0800 and before Jan 14
09:29:24 2009 -0800 ;)

Cheers,
Michael

Re: [PATCH 0/2] git checkout: one bugfix and one cosmetic change

From: Kris Shannon <hidden>
Date: 2016-06-15 22:46:24

2009/3/15 Kjetil Barvik [off-list ref]:
Just one small bugfix patch, and one small cosmetic change.

By the way, I wonder how often the list of 'Primary Authors' and
'Contributors' on the webpage http://git-scm.com/about is updated.
Should'nt it be updated when a new release, like v1.6.2, is made?
I was rather surprised to see my name on that list.  A quick git log
showed my one contribution to git-parse-remote way pack in
August 2005.

I'd forgotten about that and was feeling all warm and fuzzy until I did:
git log -- git-parse-remote

and saw that it was deleted a week later :(

Re: [PATCH 0/2] git checkout: one bugfix and one cosmetic change

From: Jeff King <hidden>
Date: 2016-06-15 22:46:24

On Tue, Mar 17, 2009 at 03:56:12PM +1100, Kris Shannon wrote:
I was rather surprised to see my name on that list.  A quick git log
showed my one contribution to git-parse-remote way pack in
August 2005.

I'd forgotten about that and was feeling all warm and fuzzy until I did:
git log -- git-parse-remote

and saw that it was deleted a week later :(
Heh. The current list just counts commits, which is nice and fast. But
one could also "git blame" all of the content from master and credit
people based either on:

  - number of surviving lines in the current codebase (which obviously
    would give very rankings for people, as the number of lines added
    in a commit is not constant)

  - number of commits which have surviving lines

Doing such a calculation would be pretty slow, though, I imagine. And it
would of course remove you from the list. :)

-Peff

Re: [PATCH 0/2] git checkout: one bugfix and one cosmetic change

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:46:24

Jeff King venit, vidit, dixit 17.03.2009 09:43:
On Tue, Mar 17, 2009 at 03:56:12PM +1100, Kris Shannon wrote:
quoted
I was rather surprised to see my name on that list.  A quick git log
showed my one contribution to git-parse-remote way pack in
August 2005.

I'd forgotten about that and was feeling all warm and fuzzy until I did:
git log -- git-parse-remote

and saw that it was deleted a week later :(
Heh. The current list just counts commits, which is nice and fast. But
one could also "git blame" all of the content from master and credit
people based either on:

  - number of surviving lines in the current codebase (which obviously
    would give very rankings for people, as the number of lines added
    in a commit is not constant)

  - number of commits which have surviving lines

Doing such a calculation would be pretty slow, though, I imagine. And it
would of course remove you from the list. :)

-Peff
Maybe we can forge a statement by Canonical, claiming they were among
the top contributors to git? Then GKH would do all the statistics for us ;)

Michael
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help