@@ -382,7 +382,7 @@ static int attr_setup(
382382{
383383 git_buf system = GIT_BUF_INIT , info = GIT_BUF_INIT ;
384384 git_attr_file_source index_source = { GIT_ATTR_FILE_SOURCE_INDEX , NULL , GIT_ATTR_FILE , NULL };
385- git_attr_file_source head_source = { GIT_ATTR_FILE_SOURCE_COMMIT , NULL , GIT_ATTR_FILE , NULL };
385+ git_attr_file_source head_source = { GIT_ATTR_FILE_SOURCE_HEAD , NULL , GIT_ATTR_FILE , NULL };
386386 git_attr_file_source commit_source = { GIT_ATTR_FILE_SOURCE_COMMIT , NULL , GIT_ATTR_FILE , NULL };
387387 git_index * idx = NULL ;
388388 const char * workdir ;
@@ -432,7 +432,12 @@ static int attr_setup(
432432 goto out ;
433433
434434 if ((opts && (opts -> flags & GIT_ATTR_CHECK_INCLUDE_COMMIT ) != 0 )) {
435- commit_source .commit_id = opts -> commit_id ;
435+ #ifndef GIT_DEPRECATE_HARD
436+ if (opts -> commit_id )
437+ commit_source .commit_id = opts -> commit_id ;
438+ else
439+ #endif
440+ commit_source .commit_id = & opts -> attr_commit_id ;
436441
437442 if ((error = preload_attr_source (repo , attr_session , & commit_source )) < 0 )
438443 goto out ;
@@ -521,8 +526,10 @@ static int attr_decide_sources(
521526 break ;
522527 }
523528
524- if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD ) != 0 ||
525- (flags & GIT_ATTR_CHECK_INCLUDE_COMMIT ) != 0 )
529+ if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD ) != 0 )
530+ srcs [count ++ ] = GIT_ATTR_FILE_SOURCE_HEAD ;
531+
532+ if ((flags & GIT_ATTR_CHECK_INCLUDE_COMMIT ) != 0 )
526533 srcs [count ++ ] = GIT_ATTR_FILE_SOURCE_COMMIT ;
527534
528535 return count ;
@@ -582,8 +589,14 @@ static int push_one_attr(void *ref, const char *path)
582589 for (i = 0 ; !error && i < n_src ; ++ i ) {
583590 git_attr_file_source source = { src [i ], path , GIT_ATTR_FILE };
584591
585- if (src [i ] == GIT_ATTR_FILE_SOURCE_COMMIT && info -> opts )
586- source .commit_id = info -> opts -> commit_id ;
592+ if (src [i ] == GIT_ATTR_FILE_SOURCE_COMMIT && info -> opts ) {
593+ #ifndef GIT_DEPRECATE_HARD
594+ if (info -> opts -> commit_id )
595+ source .commit_id = info -> opts -> commit_id ;
596+ else
597+ #endif
598+ source .commit_id = & info -> opts -> attr_commit_id ;
599+ }
587600
588601 error = push_attr_source (info -> repo , info -> attr_session , info -> files ,
589602 & source , allow_macros );
0 commit comments