summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-09-24 15:23:34 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-09-25 14:39:01 +0100
commit0f4256b8d78cf602192e0546d185953ee1b30fd5 (patch)
treee52016efb0a565d4f5e54f617d7bc22429b32849 /include
parentd6c7ca3ea99aa97d520d741dee2a8542cd0f2e38 (diff)
downloadlibgit2-0f4256b8d78cf602192e0546d185953ee1b30fd5.tar.gz
repository: improve `hashfile` for absolute paths
When `git_repository_hashfile` is handed an absolute path, it determines whether the path is within the repository's working directory or not. This is necessary when there is no `as_path` specified. If the path is within the working directory, then the given path should be used for attribute lookups (it is the effective `as_path`). If it is not within the working directory, then it is _not_ eligible. Importantly, now we will _never_ pass an absolute path down to attribute lookup functions.
Diffstat (limited to 'include')
-rw-r--r--include/git2/repository.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/include/git2/repository.h b/include/git2/repository.h
index e69901644..8d1cffc9b 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -762,13 +762,15 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(
*
* @param out Output value of calculated SHA
* @param repo Repository pointer
- * @param path Path to file on disk whose contents should be hashed. If the
- * repository is not NULL, this can be a relative path.
+ * @param path Path to file on disk whose contents should be hashed. This
+ * may be an absolute path or a relative path, in which case it
+ * will be treated as a path within the working directory.
* @param type The object type to hash as (e.g. GIT_OBJECT_BLOB)
* @param as_path The path to use to look up filtering rules. If this is
- * NULL, then the `path` parameter will be used instead. If
- * this is passed as the empty string, then no filters will be
- * applied when calculating the hash.
+ * an empty string then no filters will be applied when
+ * calculating the hash. If this is `NULL` and the `path`
+ * parameter is a file within the repository's working
+ * directory, then the `path` will be used.
* @return 0 on success, or an error code
*/
GIT_EXTERN(int) git_repository_hashfile(