@@ -599,7 +599,10 @@ extern int index_name_pos(const struct index_state *, const char *name, int name#define ADD_CACHE_KEEP_CACHE_TREE 32 /* Do not invalidate cache-tree */externintadd_index_entry(structindex_state*,structcache_entry*ce,intoption);externvoidrename_index_entry_at(structindex_state*,intpos,constchar*new_name);++/* Remove entry, return 1 if there are more entries after pos. */externintremove_index_entry_at(structindex_state*,intpos);+externvoidremove_marked_cache_entries(structindex_state*istate);externintremove_file_from_index(structindex_state*,constchar*path);#define ADD_CACHE_VERBOSE 1
@@ -503,7 +503,6 @@ int index_name_pos(const struct index_state *istate, const char *name, int namelreturnindex_name_stage_pos(istate,name,namelen,0);}-/* Remove entry, return true if there are more entries to go.. */intremove_index_entry_at(structindex_state*istate,intpos){structcache_entry*ce=istate->cache[pos];
@@ -575,7 +575,22 @@ extern int verify_path(const char *path);externintindex_dir_exists(structindex_state*istate,constchar*name,intnamelen);externvoidadjust_dirname_case(structindex_state*istate,char*name);externstructcache_entry*index_file_exists(structindex_state*istate,constchar*name,intnamelen,intigncase);++/*+*Searchesforanentrydefinedbynameandnameleninthegivenindex.+*Ifthereturnvalueispositive(including0)itisthepositionofan+*exactmatch.Ifthereturnvalueisnegative,thenegatedvalueminus1isthe+*positionwheretheentrywouldbeinserted.+*Example:Inthecurrentindexwehavethefilesb,d,e:+*index_name_pos(&index,"a",1)->-1+*index_name_pos(&index,"b",1)->0+*index_name_pos(&index,"c",1)->-2+*index_name_pos(&index,"d",1)->1+*index_name_pos(&index,"e",1)->2+*index_name_pos(&index,"f",1)->-3+*/externintindex_name_pos(conststructindex_state*,constchar*name,intnamelen);+#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
From: Stefan Beller <hidden> Date: 2017-01-18 00:31:33
When looking for documentation for a specific function, you may be tempted
to run
git -C Documentation grep index_name_pos
only to find the file technical/api-in-core-index.txt, which doesn't
help for understanding the given function. It would be better to not find
these functions in the documentation, such that people directly dive into
the code instead.
In the previous patches we have documented
* index_name_pos()
* remove_index_entry_at()
* add_[file_]to_index()
in cache.h
We already have documentation for:
* add_index_entry()
* read_index()
Which leaves us with a TODO for:
* cache -> the_index macros
* refresh_index()
* discard_index()
* ie_match_stat() and ie_modified(); how they are different and when to
use which.
* write_index() that was renamed to write_locked_index
* cache_tree_invalidate_path()
* cache_tree_update()
Signed-off-by: Stefan Beller <redacted>
---
Documentation/technical/api-in-core-index.txt | 21 ---------------------
1 file changed, 21 deletions(-)
delete mode 100644 Documentation/technical/api-in-core-index.txt
@@ -1,21 +0,0 @@-in-core index API-=================--Talk about <read-cache.c> and <cache-tree.c>, things like:--* cache -> the_index macros-* read_index()-* write_index()-* ie_match_stat() and ie_modified(); how they are different and when to- use which.-* index_name_pos()-* remove_index_entry_at()-* remove_file_from_index()-* add_file_to_index()-* add_index_entry()-* refresh_index()-* discard_index()-* cache_tree_invalidate_path()-* cache_tree_update()--(JC, Linus)
From: Stefan Beller <hidden> Date: 2017-01-18 23:30:42
v2:
included all suggestions from Junio
v1:
The two single patches[1] are turned into a series here.
[1] https://public-inbox.org/git/20170117200147.25425-1-sbeller@google.com/
Thanks,
Stefan
Stefan Beller (4):
cache.h: document index_name_pos
cache.h: document remove_index_entry_at
cache.h: document add_[file_]to_index
documentation: retire unfinished documentation
Documentation/technical/api-in-core-index.txt | 21 -------------
cache.h | 43 +++++++++++++++++++++++----
read-cache.c | 1 -
3 files changed, 38 insertions(+), 27 deletions(-)
delete mode 100644 Documentation/technical/api-in-core-index.txt
--
2.11.0.299.g762782ba8a
From: Stefan Beller <hidden> Date: 2017-01-18 23:30:23
Do this by moving the existing documentation from
read-cache.c to cache.h.
Signed-off-by: Stefan Beller <redacted>
---
cache.h | 3 +++
read-cache.c | 1 -
2 files changed, 3 insertions(+), 1 deletion(-)
@@ -603,7 +603,10 @@ extern int index_name_pos(const struct index_state *, const char *name, int name#define ADD_CACHE_KEEP_CACHE_TREE 32 /* Do not invalidate cache-tree */externintadd_index_entry(structindex_state*,structcache_entry*ce,intoption);externvoidrename_index_entry_at(structindex_state*,intpos,constchar*new_name);++/* Remove entry, return true if there are more entries to go. */externintremove_index_entry_at(structindex_state*,intpos);+externvoidremove_marked_cache_entries(structindex_state*istate);externintremove_file_from_index(structindex_state*,constchar*path);#define ADD_CACHE_VERBOSE 1
@@ -503,7 +503,6 @@ int index_name_pos(const struct index_state *istate, const char *name, int namelreturnindex_name_stage_pos(istate,name,namelen,0);}-/* Remove entry, return true if there are more entries to go.. */intremove_index_entry_at(structindex_state*istate,intpos){structcache_entry*ce=istate->cache[pos];
@@ -609,13 +609,24 @@ extern int remove_index_entry_at(struct index_state *, int pos);externvoidremove_marked_cache_entries(structindex_state*istate);externintremove_file_from_index(structindex_state*,constchar*path);-#define ADD_CACHE_VERBOSE 1-#define ADD_CACHE_PRETEND 2-#define ADD_CACHE_IGNORE_ERRORS 4-#define ADD_CACHE_IGNORE_REMOVAL 8-#define ADD_CACHE_INTENT 16++#define ADD_CACHE_VERBOSE 1 /* verbose */+#define ADD_CACHE_PRETEND 2 /* dry run */+#define ADD_CACHE_IGNORE_ERRORS 4 /* ignore errors */+#define ADD_CACHE_IGNORE_REMOVAL 8 /* do not remove files from index */+#define ADD_CACHE_INTENT 16 /* intend to add later; stage empty file */
I usually prefer having defines like these use shift operators to set
the desired bit '(1<<2)' instead of '4', etc. Is there a preference for
git as a whole? I know this is just a documentation change so maybe
this isn't even the place to discuss this.
--
Brandon Williams
@@ -609,13 +609,24 @@ extern int remove_index_entry_at(struct index_state *, int pos);externvoidremove_marked_cache_entries(structindex_state*istate);externintremove_file_from_index(structindex_state*,constchar*path);-#define ADD_CACHE_VERBOSE 1-#define ADD_CACHE_PRETEND 2-#define ADD_CACHE_IGNORE_ERRORS 4-#define ADD_CACHE_IGNORE_REMOVAL 8-#define ADD_CACHE_INTENT 16++#define ADD_CACHE_VERBOSE 1 /* verbose */+#define ADD_CACHE_PRETEND 2 /* dry run */+#define ADD_CACHE_IGNORE_ERRORS 4 /* ignore errors */+#define ADD_CACHE_IGNORE_REMOVAL 8 /* do not remove files from index */+#define ADD_CACHE_INTENT 16 /* intend to add later; stage empty file */
I usually prefer having defines like these use shift operators to set
the desired bit '(1<<2)' instead of '4', etc. Is there a preference for
git as a whole? I know this is just a documentation change so maybe
this isn't even the place to discuss this.
eh, and I forgot to remove the comments that Junio thought of as redundant.
I agree that (1<<N)) is usually better than the actual number. But I think
we do not want to change that for the same reason as we don't want to add
these comments there: Digging into history just got more complicated here.
("Who introduced ADD_CACHE_INTENT and why?" you need to skip the
reformatting/adding document patch to actually find the answer.)
Thanks for spotting,
Stefan
@@ -575,7 +575,26 @@ extern int verify_path(const char *path);externintindex_dir_exists(structindex_state*istate,constchar*name,intnamelen);externvoidadjust_dirname_case(structindex_state*istate,char*name);externstructcache_entry*index_file_exists(structindex_state*istate,constchar*name,intnamelen,intigncase);++/*+*Searchesforanentrydefinedbynameandnameleninthegivenindex.+*Ifthereturnvalueispositive(including0)itisthepositionofan+*exactmatch.Ifthereturnvalueisnegative,thenegatedvalueminus1+*isthepositionwheretheentrywouldbeinserted.+*Example:Thecurrentindexconsistsofthesefilesanditsstages:+*+*b#0,d#0,f#1,f#3+*+*index_name_pos(&index,"a",1)->-1+*index_name_pos(&index,"b",1)->0+*index_name_pos(&index,"c",1)->-2+*index_name_pos(&index,"d",1)->1+*index_name_pos(&index,"e",1)->-3+*index_name_pos(&index,"f",1)->2+*index_name_pos(&index,"g",1)->-5+*/externintindex_name_pos(conststructindex_state*,constchar*name,intnamelen);+#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
From: Stefan Beller <hidden> Date: 2017-01-19 03:19:06
v3:
* dropped commets on constants as they were not helpful
* fixed one result in the example for index_name_pos(&index, "f", 1) (which
is -3 now)
v2:
included all suggestions from Junio
v1:
The two single patches[1] are turned into a series here.
[1] https://public-inbox.org/git/20170117200147.25425-1-sbeller@google.com/
Thanks,
Stefan
Stefan Beller (4):
cache.h: document index_name_pos
cache.h: document remove_index_entry_at
cache.h: document add_[file_]to_index
documentation: retire unfinished documentation
Documentation/technical/api-in-core-index.txt | 21 -------------
cache.h | 43 +++++++++++++++++++++++----
read-cache.c | 1 -
3 files changed, 38 insertions(+), 27 deletions(-)
delete mode 100644 Documentation/technical/api-in-core-index.txt
--
2.11.0.299.g762782ba8a
@@ -575,7 +575,26 @@ extern int verify_path(const char *path);externintindex_dir_exists(structindex_state*istate,constchar*name,intnamelen);externvoidadjust_dirname_case(structindex_state*istate,char*name);externstructcache_entry*index_file_exists(structindex_state*istate,constchar*name,intnamelen,intigncase);++/*+*Searchesforanentrydefinedbynameandnameleninthegivenindex.+*Ifthereturnvalueispositive(including0)itisthepositionofan+*exactmatch.Ifthereturnvalueisnegative,thenegatedvalueminus1+*isthepositionwheretheentrywouldbeinserted.+*Example:Thecurrentindexconsistsofthesefilesanditsstages:+*+*b#0,d#0,f#1,f#3+*+*index_name_pos(&index,"a",1)->-1+*index_name_pos(&index,"b",1)->0+*index_name_pos(&index,"c",1)->-2+*index_name_pos(&index,"d",1)->1+*index_name_pos(&index,"e",1)->-3+*index_name_pos(&index,"f",1)->-3+*index_name_pos(&index,"g",1)->-5+*/externintindex_name_pos(conststructindex_state*,constchar*name,intnamelen);+#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
From: Stefan Beller <hidden> Date: 2017-01-19 03:19:13
Do this by moving the existing documentation from
read-cache.c to cache.h.
Signed-off-by: Stefan Beller <redacted>
---
cache.h | 3 +++
read-cache.c | 1 -
2 files changed, 3 insertions(+), 1 deletion(-)
@@ -603,7 +603,10 @@ extern int index_name_pos(const struct index_state *, const char *name, int name#define ADD_CACHE_KEEP_CACHE_TREE 32 /* Do not invalidate cache-tree */externintadd_index_entry(structindex_state*,structcache_entry*ce,intoption);externvoidrename_index_entry_at(structindex_state*,intpos,constchar*new_name);++/* Remove entry, return true if there are more entries to go. */externintremove_index_entry_at(structindex_state*,intpos);+externvoidremove_marked_cache_entries(structindex_state*istate);externintremove_file_from_index(structindex_state*,constchar*path);#define ADD_CACHE_VERBOSE 1
@@ -503,7 +503,6 @@ int index_name_pos(const struct index_state *istate, const char *name, int namelreturnindex_name_stage_pos(istate,name,namelen,0);}-/* Remove entry, return true if there are more entries to go.. */intremove_index_entry_at(structindex_state*istate,intpos){structcache_entry*ce=istate->cache[pos];
From: Stefan Beller <hidden> Date: 2017-01-19 03:19:14
When looking for documentation for a specific function, you may be tempted
to run
git -C Documentation grep index_name_pos
only to find the file technical/api-in-core-index.txt, which doesn't
help for understanding the given function. It would be better to not find
these functions in the documentation, such that people directly dive into
the code instead.
In the previous patches we have documented
* index_name_pos()
* remove_index_entry_at()
* add_[file_]to_index()
in cache.h
We already have documentation for:
* add_index_entry()
* read_index()
Which leaves us with a TODO for:
* cache -> the_index macros
* refresh_index()
* discard_index()
* ie_match_stat() and ie_modified(); how they are different and when to
use which.
* write_index() that was renamed to write_locked_index
* cache_tree_invalidate_path()
* cache_tree_update()
Signed-off-by: Stefan Beller <redacted>
---
Documentation/technical/api-in-core-index.txt | 21 ---------------------
1 file changed, 21 deletions(-)
delete mode 100644 Documentation/technical/api-in-core-index.txt
@@ -1,21 +0,0 @@-in-core index API-=================--Talk about <read-cache.c> and <cache-tree.c>, things like:--* cache -> the_index macros-* read_index()-* write_index()-* ie_match_stat() and ie_modified(); how they are different and when to- use which.-* index_name_pos()-* remove_index_entry_at()-* remove_file_from_index()-* add_file_to_index()-* add_index_entry()-* refresh_index()-* discard_index()-* cache_tree_invalidate_path()-* cache_tree_update()--(JC, Linus)
From: Stefan Beller <hidden> Date: 2017-01-18 23:31:39
When looking for documentation for a specific function, you may be tempted
to run
git -C Documentation grep index_name_pos
only to find the file technical/api-in-core-index.txt, which doesn't
help for understanding the given function. It would be better to not find
these functions in the documentation, such that people directly dive into
the code instead.
In the previous patches we have documented
* index_name_pos()
* remove_index_entry_at()
* add_[file_]to_index()
in cache.h
We already have documentation for:
* add_index_entry()
* read_index()
Which leaves us with a TODO for:
* cache -> the_index macros
* refresh_index()
* discard_index()
* ie_match_stat() and ie_modified(); how they are different and when to
use which.
* write_index() that was renamed to write_locked_index
* cache_tree_invalidate_path()
* cache_tree_update()
Signed-off-by: Stefan Beller <redacted>
---
Documentation/technical/api-in-core-index.txt | 21 ---------------------
1 file changed, 21 deletions(-)
delete mode 100644 Documentation/technical/api-in-core-index.txt
@@ -1,21 +0,0 @@-in-core index API-=================--Talk about <read-cache.c> and <cache-tree.c>, things like:--* cache -> the_index macros-* read_index()-* write_index()-* ie_match_stat() and ie_modified(); how they are different and when to- use which.-* index_name_pos()-* remove_index_entry_at()-* remove_file_from_index()-* add_file_to_index()-* add_index_entry()-* refresh_index()-* discard_index()-* cache_tree_invalidate_path()-* cache_tree_update()--(JC, Linus)